<style>
.order-statusins {
  width: 860px;
  margin: 0 auto 0 auto;
  overflow: hidden;
}
.order-statusins li {
  float: left;
  width: 172px;
  text-align: center;
}
.consigneeinfo,
.order-payment {
  margin: 20px 0;
}
.consigneeinfo {
  font-size: 16px;
  line-height: 20px;
  margin: 20px auto 40px auto;
}
.order-goods {
  margin-bottom: 20px;
  text-align: center;
}
.order-goods th {
  border-bottom: 1px solid #e3e3e3;
  padding: 4px 10px;
  background-color: #f8f8f8;
  font-size: 16px;
  font-weight: normal;
  vertical-align: middle;
}
.order-goods td {
  border-bottom: 1px solid #e3e3e3;
  padding: 10px;
  vertical-align: middle;
}
.order-goods .describe {
  font-weight: normal;
  line-height: 20px;
}
</style>
<div class="partner-title">
  <strong class="pull-left"><?php echo L('order_sn');?>: <?php echo $orderInfo['order_sn']; ?></strong>
  <?php if($orderInfo['order_status']==OrderModel::ORDER_CONFIRMED && in_array($orderInfo['shipping_status'], array(OrderModel::SHIPPING_SHIPPED ,OrderModel::SHIPPING_SHIPPED_PART))):?>
  <a href="<?php echo url('order/order_edit_status', array('oid' => $orderInfo['id'], 'status' => OrderModel::ORDER_COMPLETE));?>" class="btn pull-right"><?php echo L('confrim_order');?></a>
  <?php endif;?>

  <?php if($orderInfo['car_type'] && $orderInfo['payment_status'] == OrderModel::PAY_PAYED && $orderInfo['order_status'] !=2):?>
    <?php if($orderInfo['pay_return']){?>
      <?php echo $orderInfo['return_status'];?>
      <?php }else{?>
        <?php if($orderInfo['productList'][0]['refund']){?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>)" class="btn pull-right"><?php echo L('application_for_drawback');?></a>
        <?php }else{?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>, <?php echo L('if_he_will_notbe_deposit');?>【<?php echo currency($orderInfo['productList'][0]['yufu_price']);?>】<?php echo L('return');?>')" class="btn pull-right"><?php echo L('application_for_drawback');?></a>
      <?php }?>
    <?php }?>
  <?php endif;?>
</div>
<!-- 收货人信息 -->
<div class="partner-title"><?php echo L('consignee');?></div>
<div class="consigneeinfo">
<div><?php echo isset($orderInfo['delivery_first_name']) ? $orderInfo['delivery_first_name'] : ''; ?>,<?php echo isset($orderInfo['delivery_last_name']) ? $orderInfo['delivery_last_name'] : ''; ?>/<?php echo isset($orderInfo['delivery_address']) ? $orderInfo['delivery_address'] : ''; ?>,<?php echo isset($orderInfo['delivery_city']) ? $orderInfo['delivery_city'] : ''; ?>,<?php echo isset($orderInfo['delivery_province']) ? $orderInfo['delivery_province'] : ''; ?>,<?php echo isset($orderInfo['delivery_country']) ? $orderInfo['delivery_country'] : ''; ?>/<?php echo isset($orderInfo['delivery_phone']) ? $orderInfo['delivery_phone'] : ''; ?></div>
<div><?php echo isset($orderInfo['delivery_email']) ? $orderInfo['delivery_email'] : ''; ?>/<?php echo isset($orderInfo['delivery_postcode']) ? $orderInfo['delivery_postcode'] : ''; ?></div>
</div>
<!-- 备注 -->
<div class="partner-title"><?php echo L('remark');?></div>
<div class="consigneeinfo">
<div><?php echo isset($orderInfo['remark']) ? $orderInfo['remark'] : ''; ?></div>
</div>
<!-- 配送支付方式 -->
<div class="partner-title"><?php echo L('shipping_method');?></div>
<div class="clearfix order-payment">
  <p class="pull-left">
    <?php echo L('shippingmethod');?>:
    <strong><?php echo isset($orderInfo['shipping_method_name']) ? $orderInfo['shipping_method_name'] : null ?>
    (<?php echo $orderInfo['shipping_method'];?><?php echo !empty($orderInfo['shipping_no']) ? ':'.$orderInfo['shipping_no'] : '';?>)
    </strong>
  </p>

  <?php if($orderInfo['car_type'] && $orderInfo['payment_status'] == OrderModel::PAY_PAYED && $orderInfo['order_status'] !=2):?>
    <?php if($orderInfo['pay_return']){?>
      <?php echo $orderInfo['return_status'];?>
      <?php }else{?>
        <?php if($orderInfo['productList'][0]['refund']){?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>)" class="pull-right"><?php echo L('user_changer_order_details')?></a>
        <?php }else{?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>, <?php echo L('if_he_will_notbe_deposit');?>【<?php echo currency($orderInfo['productList'][0]['yufu_price']);?>】<?php echo L('return');?>')" class="pull-right"><?php echo L('user_changer_order_details')?></a>
        <?php }?>
    <?php }?>
  <?php endif;?>
</div>
<form action="/partner/update_order/oid/<?php echo $_GET['oid']?>" method="post">
<!--订单商品-->
<table class="order-goods">
  <tr>
    <th width="10%"><?php echo L('product_image')?></th>
    <th width="40%"><?php echo L('order_goods');?></th>
    <th width="10%"><?php echo L('goods_price');?></th>
    <th width="10%"><?php echo L('goods_number');?></th>
    <th width="10%"><?php echo L('amount_about');?></th>
    <th width="20%"><?php echo L('figure_data');?></th>
  </tr>
  <?php
    if (isset($orderInfo['productList'])):
      foreach ($orderInfo['productList'] as $k => $product):
  ?>
  <tr>
    <td><img src="<?php echo $product['small_img'] ?>" alt="goods image" width="50" height="50" /></td>
    <td>
      <?php echo $product['product_name'] ?>
      <?php if($product['custom_type']==2):?>
      <?php
        $size_type = $product['size_type'];
        $attributeList = $product['attributeList'];
      ?>
      <div class="hide align-left pt2x pb2x custom-list js-custom-list"><?php include THEMES_PATH . 'public/check_options.phtml'; ?></div>
      <?php endif; ?>
    </td>
    <td><?php echo currency(($product['total_amount']-$product['pants_price']*$product['pants_qty'])/$product['qty']);?></td>
    <td><?php echo $product['qty'] ?></td>
    <td><?php echo currency($product['total_amount']-$product['pants_price']*$product['pants_qty']);?></td>
    <td>
      <?php if($product['model_id'] == 25):?>
      <strong class="text-bold">
        <?php
          $attr_id = 161;
          $attr = $attributeList[$attr_id];
        ?>
        <?php foreach ($attr['values'] as $attrv):?>
        <?php if($attr['default'] == $attrv['product_attr_id']):?>
        <?php echo $attrv['label'];?>:
        <?php endif;?>
        <?php endforeach;?>
        <?php
          $attr_id = 162;
          $attr = $attributeList[$attr_id];
        ?>
        <?php if(isset($attr['default']) && $attr['default']){echo $attr['default'];}?>
      </strong>
      <?php endif;?>
      <?php if($product['measure_id']):?>
        <?php
        $measureInfo = AttributeModel::get_user_measure_info($product['measure_id']);
          if($measureInfo['m_status'] == 5):
        ?>
          <p>
          <?php foreach(unserialize($measureInfo['measure_data']) as $mskey=>$msval):?>
          <?php echo MeasureModel::msizedataShow($mskey);?>:<strong class="text-bold"><?php echo $msval;?></strong><br />
          <?php endforeach;?>
          </p>
        <?php else:?>
          <?php echo $measureInfo['measure_name'];?>
        <?php endif;?>
      <?php endif;?>
      </td>
    </tr>
    <?php if($product['pants_qty'] > 0):?>
    <tr>
      <td></td>
      <td><?php echo L('AdditionalPants'); ?></td>
      <td><?php echo currency($product['pants_price']);?></td>
      <td><?php echo $product['pants_qty'] ?></td>
      <td><?php echo currency($product['pants_price']*$product['pants_qty']);?></td>
      <td></td>
    </tr>
    <?php endif;?>
    <?php
        endforeach;
      endif;
    ?>
  </table>
  <div class="align-right"><?php //if($orderInfo['payment_status'] == OrderModel::PAY_UNPAYED) : echo isset($paymentSubmit) ? $paymentSubmit : null; endif;?>
    <?php if($orderInfo['order_status'] == OrderModel::ORDER_UNCONFIRMED && $orderInfo['payment_status'] == OrderModel::PAY_UNPAYED):?>
    <input type="hidden" name="surplus_money" id="surplus_money" value="0" />
    <input type="hidden" name="info_user_money" id="info_user_money" value="<?php echo $user_money;?>" />
    <input type="hidden" name="info_pay_amount" id="info_pay_amount" value="<?php echo $orderInfo['pay_amount'];?>" />
    <input class="pay_button" type="submit" value="<?php echo L('_PAY_NOW_');?>" />
    <?php endif;?>
  </div>
</form>
<script src="/statics/front/js/scripts/cart.js"></script>
<script>
$(function () {
  var use_balance_flag = $('#is_user_money').is(':checked');
  if (use_balance_flag == true) {
    get_user_money();
  }

  //选择支付方式
  $('.js-payment-method').on('click', 'dd', function() {
    var $this = $(this);
    $this.closest('.js-payment-method').find('dt > input[type=hidden]').val($this.data('info'));
    $this.addClass('selected').parent().siblings().find("dd").removeClass('selected');
    getPaymentMoney();
  });

  /*检查定制选项*/
  $('.js-check-options').on('click', function () {//定制项弹出框
    $(this).next('.modal').modal('show');
  });
});

function confirmurl(url, message) {
  if (confirm(message)) {
    redirect(url);
  }
}

function redirect(url) {
  location.href = url;
}

function get_user_money() {
  var use_balance_flag = $('#is_user_money').is(":checked");
  var user_money = parseFloat($('#info_user_money').val());
  var pay_amount = parseFloat($('#info_pay_amount').val());
  var surplus_money = 0;

  if (use_balance_flag == true) {
    if (user_money > 0 && user_money < pay_amount ) {
      pay_amount =  pay_amount - user_money;
      surplus_money = user_money;
      user_money = 0;
    } else if(user_money > 0 && user_money > pay_amount) {
      user_money = user_money - pay_amount;
      surplus_money = pay_amount;
      pay_amount = 0;
    }

    $.ajax({
      url:'/public/paymentc/price/' + pay_amount,
      type:'get',
      error: function() {
        alert('error');
      },
      success: function(data) {
        $('#pay_amount').html(data);
      }
    });
    $.ajax({
      url:'/public/paymentc/price/' + user_money,
      type:'get',
      error: function() {
        alert('error');
      },
      success: function(data) {
        $('#user_money_1').html(data);
      }
    });
  } else {
    $.ajax({
      url:'/public/paymentc/price/' + pay_amount,
      type:'get',
      error:function(){
        alert('error');
      },
      success:function(data){
        $('#pay_amount').html(data);
      }
    });
    $.ajax({
      url:'/public/paymentc/price/' + user_money,
      type:'get',
      error: function () {
        alert('error');
      },
      success: function (data) {
        $('#user_money_1').html(data);
      }
    });
  }
  $('#surplus_money').val(surplus_money);
}
</script>